<%@page import="org.asportoonline.entities.Locale" %>
<%@page import="org.asportoonline.entities.Cliente" %>
<%
    String usertype = "viewer";

    Locale l = (Locale) request.getAttribute("locale");
    Cliente c = null;

    if (session.getAttribute("userid") != null && request.getAttribute("cliente") != null) {
        c = (Cliente) request.getAttribute("cliente");

        if (l.getProprietario().getIdCliente() == c.getIdCliente()) {
            usertype = "proprietario";
        }
    }

    String localita = l.getIndirizzo().getCitta();
    long idlocale = l.getIdLocale();
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tlds/asportoonline.tld" prefix="asportoonline" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AsportoOnline | Dettagli locale</title>
        <style type="text/css">
            @import url("style.css");
        </style>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 
<script type="text/javascript">
var initialize = function() {
 
  // fornisce latitudine e longitudine
  var lat = document.getElementById('lat').getAttribute("value");
  var lon = document.getElementById('lon').getAttribute("value");
  //alert(lat);
  var latlng = new google.maps.LatLng(lat, lon);
   
  // imposta le opzioni di visualizzazione
  var options = { zoom: 17,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                };
                 
  // crea l'oggetto mappa
  var map = new google.maps.Map(document.getElementById('map'), options);
  
  //alert(document.getElementById('nomeLocale').innerHTML);  
  var marker = new google.maps.Marker({ position: latlng,
                                      map: map, 
                                      title: document.getElementById('nomeLocale').innerHTML });
}
 
window.onload = initialize;
</script>
    </head>
    <body>
        <div class="meister">
            <div class="page">
                <div class="container">
                    <%@ include file="/WEB-INF/common/header.jsp"%>
                    <div class="navigation"> <a id="first" href="MainController?q=index">Home</a> > 
                        <% if(usertype == "proprietario") { %>
                        <a href="MainController?q=fetch_restaurants_data_action&amp;ret=list_restaurants">I miei locali</a> 
                        <% } else { %>
                        <a href="MainController?q=view_restaurants_by_locality&amp;loc=<%=localita%>">Risultati</a> 
                        <% } %>
                        > Dettagli locale </div>  

                    <div class="uniform_background">

                        <div class="listaLocali">
                            <h1>Dettagli locale
                                <% if (usertype.equals("proprietario")) {%>
                                - <a href="MainController?q=fetch_restaurant_details_action&AMP;ret=modify_restaurant&AMP;idlocale=<%=idlocale%>">Modifica dati</a>
                                - <a href="MainController?q=delete_restaurant_action&AMP;idlocale=<%=idlocale%>">Elimina locale</a>
                                <% }%>
                            </h1>
                            <asportoonline:dettagli_locale locale="${locale}"></asportoonline:dettagli_locale>
                            </div>

                            <div class="listaProdotti">
                                <h1>Dettagli prodotti
                                <% if (usertype.equals("proprietario")) {%>
                                - <a href="MainController?q=register_product&AMP;idlocale=<%=idlocale%>">Inserisci prodotto</a>
                                - <a href="MainController?q=fetch_restaurant_prenotations_action&AMP;idlocale=<%=idlocale%>">Vedi prenotazioni</a>
                                <% }%>                                    
                            </h1>
                            <asportoonline:elenco_prodotti_locale prodotti="${prodotti}" cliente="<%=c%>"></asportoonline:elenco_prodotti_locale>

                            </div>                     

                        </div>

                    <%@ include file="/WEB-INF/common/footer.jsp"%>
                </div>
            </div>
        </div>
    </body>
</html>
